package whf.framework.workflow.dao;

import whf.framework.dao.DAOImp;
import whf.framework.exception.CreateException;
import whf.framework.workflow.entity.WorkflowDefinition;
import whf.framework.workflow.entity.WorkflowEntity;

public class WorkflowEntityDAOImp extends DAOImp<WorkflowEntity> implements WorkflowEntityDAO {

	@Override
	public void create(WorkflowEntity entity) throws CreateException {
		WorkflowDefinition d = entity.getWorkflowDefinition();
		if(d == null) {
			throw new CreateException("Workflow definition can not be null!");
		}
		if(d.getCurrentVersion() != null) { //如果是流程的主版本
			entity.setWorkflowDefinition(d.getCurrentVersion());
		}
		super.create(entity);
	}
	
}
